<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - drectangle_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2015  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_DRECTANGLe_ABSTRACT_H_
<font color='#0000FF'>#ifdef</font> DLIB_DRECTANGLe_ABSTRACT_H_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='rectangle_abstract.h.html'>rectangle_abstract.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='drectangle'></a>drectangle</b>
    <b>{</b>
        <font color='#009900'>/*!
            INITIAL VALUE
                The initial value of this object is defined by its constructor.                

            WHAT THIS OBJECT REPRESENTS
                This object is just like dlib::rectangle except that it stores the
                coordinates of the rectangle using double rather than long variables.  As
                such, this object represents a rectangular region inside an image.  The
                region is the rectangle with its top left corner at position (left(),top())
                and its bottom right corner at (right(),bottom()).

                Note that the origin of the coordinate system, i.e. (0,0), is located at
                the upper left corner.  That is, points such as (1,1) or (3,5) represent
                locations that are below and to the right of the origin.

                Also note that rectangles where top() &gt; bottom() or left() &gt; right()
                represent empty rectangles.
        !*/</font>
    <font color='#0000FF'>public</font>:

        <b><a name='drectangle'></a>drectangle</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #left() == 0
                - #top() == 0
                - #right() == -1 
                - #bottom() == -1 
                - #is_empty() == true
        !*/</font>

        <b><a name='drectangle'></a>drectangle</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>double</u></font> left_,
            <font color='#0000FF'><u>double</u></font> top_,
            <font color='#0000FF'><u>double</u></font> right_,
            <font color='#0000FF'><u>double</u></font> bottom_
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #left() == left_
                - #top() == top_
                - #right() == right_
                - #bottom() == bottom_
        !*/</font>

        <b><a name='drectangle'></a>drectangle</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #left()   == p.x()
                - #top()    == p.y()
                - #right()  == p.x()
                - #bottom() == p.y()
        !*/</font>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <b><a name='drectangle'></a>drectangle</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p1,
            <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font>U,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p2
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this == drectangle(p1) + drectangle(p2)
        !*/</font>

        <b><a name='drectangle'></a>drectangle</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this represents the same rectangle as rect
        !*/</font>

        <b><a name='drectangle'></a>drectangle</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - left()   == rect.left()
                - top()    == rect.top()
                - right()  == rect.right()
                - bottom() == rect.bottom()
                - dcenter(*this) == dcenter(rect)
                - width() == rect.width()
                - height() == rect.height()
        !*/</font>

        <b><a name='operator'></a>operator</b> <b><a name='rectangle'></a>rectangle</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns a rectangle where left(), top(), right(), and bottom() have been
                  rounded to the nearest integer values.
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='left'></a>left</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns the x coordinate for the left side of this rectangle
        !*/</font>

        <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> <b><a name='left'></a>left</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - returns a non-const reference to the x coordinate for the left side 
                  of this rectangle
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='top'></a>top</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns the y coordinate for the top of this rectangle
        !*/</font>

        <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> <b><a name='top'></a>top</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - returns a non-const reference to the y coordinate for the 
                  top of this rectangle
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='right'></a>right</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns the x coordinate for the right side of this rectangle
        !*/</font>

        <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> <b><a name='right'></a>right</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - returns a non-const reference to the x coordinate for the right 
                  side of this rectangle
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='bottom'></a>bottom</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns the y coordinate for the bottom of this rectangle
        !*/</font>
       
        <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> <b><a name='bottom'></a>bottom</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - returns a non-const reference to the y coordinate for the bottom 
                  of this rectangle
        !*/</font>
       
        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='tl_corner'></a>tl_corner</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns vector&lt;double,2&gt;(left(), top()) 
                  (i.e. returns the top left corner point for this rectangle)
        !*/</font>

        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='bl_corner'></a>bl_corner</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns vector&lt;double,2&gt;(left(), bottom()) 
                  (i.e. returns the bottom left corner point for this rectangle)
        !*/</font>

        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='tr_corner'></a>tr_corner</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns vector&lt;double,2&gt;(right(), top()) 
                  (i.e. returns the top right corner point for this rectangle)
        !*/</font>

        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='br_corner'></a>br_corner</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns vector&lt;double,2&gt;(right(), bottom()) 
                  (i.e. returns the bottom right corner point for this rectangle)
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='width'></a>width</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (is_empty()) then
                    - returns 0
                - else
                    - returns the width of this rectangle.
                      (i.e. right() - left() + 1)
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='height'></a>height</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (is_empty()) then
                    - returns 0
                - else
                    - returns the height of this rectangle.
                      (i.e. bottom() - top() + 1)
        !*/</font>

        <font color='#0000FF'><u>double</u></font> <b><a name='area'></a>area</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns width()*height()
        !*/</font>

        <font color='#0000FF'><u>bool</u></font> <b><a name='is_empty'></a>is_empty</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (top() &gt; bottom() || left() &gt; right()) then
                    - returns true
                - else
                    - returns false
        !*/</font>

        drectangle <b><a name='operator'></a>operator</b> <font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rhs
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (rhs.is_empty() == false &amp;&amp; this-&gt;is_empty() == false) then
                    - returns the smallest rectangle that contains both *this and 
                      rhs.
                - if (rhs.is_empty() == true &amp;&amp; this-&gt;is_empty() == false) then
                    - returns *this
                - if (rhs.is_empty() == false &amp;&amp; this-&gt;is_empty() == true) then
                    - returns rhs
                - if (rhs.is_empty() == true &amp;&amp; this-&gt;is_empty() == true) then
                    - returns a rectangle that has is_empty() == true
        !*/</font>

        drectangle <b><a name='intersect'></a>intersect</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rhs
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (there is a region of intersection between *this and rhs) then
                    - returns a rectangle that represents the intersection of *this 
                      and rhs.
                - else
                    - returns a rectangle where is_empty() == true
        !*/</font>

        <font color='#0000FF'><u>bool</u></font> <b><a name='contains'></a>contains</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (the point (p.x(),p.y()) is contained in this rectangle) then
                    - returns true
                - else
                    - returns false
        !*/</font>

        <font color='#0000FF'><u>bool</u></font> <b><a name='contains'></a>contains</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <font color='#009900'>/*!
            ensures
                - if (rect + *this == *this) then
                    - returns true
                      (i.e. returns true if *this contains the given rectangle)
                - else
                    - returns false
        !*/</font>

        drectangle<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>*</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> scale
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - performs: *this = *this*scale;
                - returns #*this
        !*/</font>

        drectangle<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>/</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> scale
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            requires
                - scale != 0
            ensures
                - performs: *this = *this*(1.0/scale);
                - returns #*this
        !*/</font>

        drectangle<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - performs: *this = *this + drectangle(p)
                - returns #*this
        !*/</font>

        <font color='#0000FF'><u>bool</u></font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - if (top() == rect.top() &amp;&amp; left() == rect.left() &amp;&amp;
                      right() == rect.right() &amp;&amp; bottom() == rect.bottom()) then
                    - returns true
                - else
                    - returns false
        !*/</font>

        <font color='#0000FF'><u>bool</u></font> <b><a name='operator'></a>operator</b><font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#009900'>/*!
            ensures
                - returns !(*this == rect)
        !*/</font>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> item, 
        std::ostream<font color='#5555FF'>&amp;</font> out
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        provides serialization support 
    !*/</font>

    <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
        drectangle<font color='#5555FF'>&amp;</font> item, 
        std::istream<font color='#5555FF'>&amp;</font> in
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        provides deserialization support 
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    std::ostream<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font>
        std::ostream<font color='#5555FF'>&amp;</font> out, 
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> item 
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - writes item to out in the form "[(left, top) (right, bottom)]"
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    std::istream<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>
        std::istream<font color='#5555FF'>&amp;</font> in, 
        drectangle<font color='#5555FF'>&amp;</font> item 
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - reads a drectangle from the input stream in and stores it in #item.  The data
              in the input stream should be of the form [(left, top) (right, bottom)]
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='center'></a>center</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns the center of the given rectangle
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font> <b><a name='dcenter'></a>dcenter</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns the center of the given rectangle.  (Both center() and dcenter() are
              identical when applied to drectangle objects)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> scale 
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - This function returns a rectangle that has the same center as rect but with
              dimensions that are scale times larger.  That is, we return a new rectangle R
              such that:
                - center(R) == center(rect)
                - R.right()-R.left() == (rect.right()-rect.left())*scale
                - R.bottom()-R.top() == (rect.bottom()-rect.top())*scale
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> scale,
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns rect*scale
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='operator'></a>operator</b><font color='#5555FF'>/</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'>const</font> <font color='#0000FF'><u>double</u></font><font color='#5555FF'>&amp;</font> scale
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns rect*(1.0/scale)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='operator'></a>operator</b><font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> r,
        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns r + drectangle(p)
              (i.e. returns the rectangle that contains both r and p)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='operator'></a>operator</b><font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> r
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns r + drectangle(p)
              (i.e. returns the rectangle that contains both r and p)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    drectangle <b><a name='translate_rect'></a>translate_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font>T,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns a rectangle R such that:
                - R.left()   == rect.left()   + p.x()
                - R.right()  == rect.right()  + p.x()
                - R.top()    == rect.top()    + p.y()
                - R.bottom() == rect.bottom() + p.y()
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='intersect'></a>intersect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> a,
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> b
    <font face='Lucida Console'>)</font>; 
    <font color='#009900'>/*!
        ensures
            - returns a.intersect(b)
              (i.e. returns a rectangle representing the intersection of a and b)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'><u>double</u></font> <b><a name='area'></a>area</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> a
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns a.area()
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='centered_drect'></a>centered_drect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>2</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> p,
        <font color='#0000FF'><u>double</u></font> width,
        <font color='#0000FF'><u>double</u></font> height
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns a rectangle R such that:
                - center(R) == p
                - if (width &lt; 1 || height &lt; 1)
                    - R.width() == 0 
                    - R.height() == 0 
                    - R.is_empty() == true
                - else
                    - R.width() == width
                    - R.height() == height 
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='centered_drect'></a>centered_drect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> width,
        <font color='#0000FF'><u>double</u></font> height
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns centered_drect(center(rect), width, height)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>const</font> drectangle <b><a name='shrink_rect'></a>shrink_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> num 
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns drectangle(rect.left()+num, rect.top()+num, rect.right()-num, rect.bottom()-num)
              (i.e. shrinks the given drectangle by shrinking its border by num)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>const</font> drectangle <b><a name='grow_rect'></a>grow_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> num 
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - return shrink_rect(rect, -num)
              (i.e. grows the given drectangle by expanding its border by num)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>const</font> drectangle <b><a name='shrink_rect'></a>shrink_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> width,
        <font color='#0000FF'><u>double</u></font> height
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - returns drectangle(rect.left()+width, rect.top()+height, rect.right()-width, rect.bottom()-height)
              (i.e. shrinks the given drectangle by shrinking its left and right borders by width
              and its top and bottom borders by height. )
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>const</font> drectangle <b><a name='grow_rect'></a>grow_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> width,
        <font color='#0000FF'><u>double</u></font> height
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        ensures
            - return shrink_rect(rect, -width, -height)
              (i.e. grows the given drectangle by expanding its border)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>const</font> drectangle <b><a name='scale_rect'></a>scale_rect</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> scale
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - scale &gt; 0
        ensures
            - return drectangle(rect.left() * scale, rect.top() * scale, rect.right() * scale, rect.bottom() * scale)
              (i.e. resizes the given rectangle by multiplying all side coordinates with a scale factor)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='set_rect_area'></a>set_rect_area</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> area
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - area &gt;= 0
        ensures
            - Returns a rectangle R such that:
                - center(R) == center(rect)
                - R has the same aspect ratio as rect.  If rect.area() == 0 then the
                  returned rect has a 1:1 aspect ratio.
                - R.area() == area
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    drectangle <b><a name='set_aspect_ratio'></a>set_aspect_ratio</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> drectangle<font color='#5555FF'>&amp;</font> rect,
        <font color='#0000FF'><u>double</u></font> ratio
    <font face='Lucida Console'>)</font>;
    <font color='#009900'>/*!
        requires
            - ratio &gt; 0
        ensures
            - This function reshapes the given rectangle so that it has the given aspect
              ratio.  In particular, this means we return a rectangle R such that the
              following equations are true:
                - R.width()/R.height() == ratio
                - R.area() == rect.area()
                - dcenter(rect) == dcenter(R)
    !*/</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_DRECTANGLe_ABSTRACT_H_
</font>

</pre></body></html>